package com.xpc.controller.utils;

import java.util.Random;

/**
 * Project：UniversityGradeAdministrationSystem
 * Date：2022/4/15
 * Time：15:23
 * Description：生成Salt
 *
 * @author 南北辰的键盘
 * @version 1.0
 */
public class SaltGeneration {



    /**
        * @description 添加了两个获取盐的方法
        * @deprecated
        * @param n=20 || n
        * @return  java.lang.String
        * @author Qinkuer
        * @Date  2022/5/14
        */
    public static String getSalt(int n) {
        char[] chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()".toCharArray();
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < n; i++) {
            char aChar = chars[new Random().nextInt(chars.length)];
            sb.append(aChar);
        }
        return sb.toString();
    }
    public static String getSalt() {
        return getSalt(20);
    }
}
